package com.yhy.wxzn.wcs.device.rgv.enums;


import com.alibaba.fastjson.serializer.JSONSerializable;
import com.alibaba.fastjson.serializer.JSONSerializer;
import com.baomidou.mybatisplus.annotation.EnumValue;

import java.io.IOException;
import java.lang.reflect.Type;

public enum NodeType  implements JSONSerializable {
    /**
     * 禁用
     */
    B(0, "B", "禁用"),
    /**
     * Station 工位
     */
    ST(1, "ST", "工位"),
    /**
     * 货位-存货库位(可拣货)
     */
    P(2, "P", "货位"),

    /**
     * 通道
     */
    R(3, "R", "通道"),

    /**
     * 提升机
     */
    L(4, "L", "提升机"),
    /**
     * 充电桩
     */
    C(5, "C", "充电桩"),
    /**
     * 接驳点（小车和输送线交互的点）
     */
    CONNECTION(6, "CONNECTION", "接驳点"),
    /**
     * 收货库位-WMS用
     */
    RL(7, "RL", "收货库位"),
    /**
     * 备货库位-WMS用
     */
    SL(8, "SL", "备货库位"),
    ;

    private String code;
    private String describe;
    @EnumValue
    private Integer codeNum;


    public static NodeType parseNodeType(Integer n){
        for (NodeType value : NodeType.values()) {
            if (value.getCodeNum().equals(n)){
                return value;
            }
        }
        throw new RuntimeException("NodeType中不存在"+n);
    }


    NodeType(Integer codeNum, String code, String describe) {
        this.codeNum = codeNum;
        this.code = code;
        this.describe = describe;
    }

    public String getCode() {
        return code;
    }

    public String getDescribe() {
        return describe;
    }

    public Integer getCodeNum() {
        return codeNum;
    }

    @Override
    public void write(JSONSerializer jsonSerializer, Object o, Type type, int i) throws IOException {
        jsonSerializer.write(this.getDescribe());
    }
}
